package cn.com.open.itembank.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * 试卷模块（部分）.
 */
public class PaperPartDto {
    /**
     * Instantiates a new Paper part.
     */
    public PaperPartDto() {
        mediaType = 0;
        totalDuration = 0;
        paperSectionDtos = new ArrayList<>();
    }

    /**
     * Instantiates a new Paper part.
     *
     * @param curMediaType the cur media type
     */
    public PaperPartDto(Integer curMediaType) {
        mediaType = curMediaType;
        paperSectionDtos = new ArrayList<>();
    }

    /**
     * The Media type.
     */
    private Integer mediaType;

    /**
     * The Total duration.
     */
    private double totalDuration;

    /**
     * The Paper sections.
     */
    private List<PaperSectionDto> paperSectionDtos;

    /**
     * Gets paper sections.
     *
     * @return the paper sections
     */
    public List<PaperSectionDto> getPaperSectionDtos() {
        if (paperSectionDtos == null) {
            paperSectionDtos = new ArrayList<>();
        }
        return paperSectionDtos;
    }

    /**
     * Gets media type.
     *
     * @return the media type
     */
    public Integer getMediaType() {
        return mediaType;
    }

    /**
     * Sets media type.
     *
     * @param mediaType the media type
     */
    public void setMediaType(Integer mediaType) {
        this.mediaType = mediaType;
    }

    /**
     * Gets total duration.
     *
     * @return the total duration
     */
    public double getTotalDuration() {
        return totalDuration;
    }

    /**
     * Sets total duration.
     *
     * @param totalDuration the total duration
     */
    public void setTotalDuration(double totalDuration) {
        this.totalDuration = totalDuration;
    }

    /**
     * copy paper part.
     *
     * @return the paper part
     */
    public PaperPartDto copy() {
        PaperPartDto copy = new PaperPartDto();
        copy.mediaType = mediaType;
        copy.totalDuration = totalDuration;

        for (PaperSectionDto paperSectionDto : paperSectionDtos) {
            copy.paperSectionDtos.add(paperSectionDto.copy());
        }

        return copy;
    }
}
